#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QInputDialog>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    resize(800, 600);

    QPushButton* btn = new QPushButton("输入框", this);

    QInputDialog* idlg = new QInputDialog(this);

    // connect(btn, &QPushButton::clicked, [=](){
    //     double d = idlg->getDouble(this, "输入框", "浮点型");
    //     qDebug() << "d= " <<d;
    // });

    // connect(btn, &QPushButton::clicked, [=](){
    //     int i = idlg->getInt(this, "输入框", "Int");
    //     qDebug() << "i= " << i;
    // });

    connect(btn, &QPushButton::clicked, [=](){
        QStringList items;
        items << tr("Spring") << tr("Summer") << tr("Fall") << tr("Winter");
        QString item = idlg->getItem(this, "输入框", "Item", items);
        qDebug() << "item: "<< item.toUtf8().data();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}
